//
//  PMineResumeViewController.m
//  Btpin
//
//  Created by Vic on 2019/3/23.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "PMineResumeViewController.h"
#import "PMineResumeInfoModel.h"
#import "PMineResumeHeaderView.h"
#import "MineBaseInfoViewController.h"
#import "PMineResumeCell.h"
#import "PMineResumeEducationViewController.h"
#import "PMineResumeSelfDescriptionViewController.h"
#import "PMineResumeWorkViewController.h"
#import "PMineResumeTrainingViewController.h"
#import "PMineResumeProjectViewController.h"
#import "PMineResumeCredentViewController.h"
#import "PMineResumeLanguageViewController.h"
#import "PMineResumeTagsViewController.h"
#import "PMineResumeIntentionViewController.h"
#import "WorkerResumeViewController.h"
#import "RealNameAuthenticationViewController.h"
#import "LYJobHuntingController.h"
#import "QRCodeViewController.h"

@interface PMineResumeViewController ()<UITableViewDelegate, UITableViewDataSource, PMineResumeHeaderViewDelegate, PMineResumeSelfDescriptionViewControllerDelegate, PSSingleRowViewDelegate, PMineResumeWorkViewControllerDelegate, PMineResumeEducationViewControllerDelegate, PMineResumeTrainingViewControllerDelegate, PMineResumeProjectViewControllerDelegate, PMineResumeCredentViewControllerDelegate, PMineResumeLanguageViewControllerDelegate, PMineResumeTagsViewControllerDelegate, PMineResumeIntentionViewControllerDelegate>
{
    PMineResumeInfoModel *infoModel;
    
    UISwitch *switchBtn;
    UITableView *resumeTableView;
    
    PMineResumeHeaderView *firstHeaderView;
    UIView *lastFooterView;
    
    BOOL isRefreshFlag; // 刚进来时不刷新tableView，当进行编辑的时候，刷新
}
@property (nonatomic, strong) PSSingleRowView *statusPickerView;
@end

@implementation PMineResumeViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (self.statusPickerView) {
        self.statusPickerView.hidden = YES;
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"我的简历";
    
    isRefreshFlag = NO;
    self.statusPickerView = [[PSSingleRowView alloc] initWithData:[DataToolsControl sharedManager].allCategoryInfoModel.currentArray target:self];
    self.statusPickerView.hidden = YES;
    
    [self loadData];
//    [self initUI];
}
- (void)loadData {
    self.noDataView.hidden = YES;
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    
    [BaseNetManager requestWithMethod:POST path:PersonMineResume_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            self->infoModel = [[PMineResumeInfoModel alloc] init];
            [self->infoModel setValuesForKeysWithDictionary:data];
            SVPHUDDismiss;
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
        if (self->isRefreshFlag) {
            [self->resumeTableView reloadData];
        } else {
            [self initUI];
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (void)editBtnTap {
    QRCodeViewController *QRCVC = [[QRCodeViewController alloc] init];
    QRCVC.pushVCType = VCPushTypeOfEditPersonalResume;
    __weak __typeof(self)weakSelf = self;
    QRCVC.edit = ^(BOOL editFlag) {
        if (editFlag) {
            __strong __typeof(weakSelf)strongSelf = weakSelf;
            self->isRefreshFlag = YES;
            [strongSelf loadData];
        }
    };
    QRCVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:QRCVC animated:YES];
}
- (void)initUI {
    UIButton *refreshBtn = [UIToolsControl initButtonWithFrame:CGRectMake(WIDTH-50*Scale, HeightOfStatusBar+3*Scale, 50*Scale, 36*Scale) imageName:nil target:self action:@selector(refreshBtnTap) title:@"刷新" titleColor:THEMECOLOR_OF_ORANGE];
    refreshBtn.titleLabel.font = Font(Font_15);
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:refreshBtn];
    UIButton *editBtn = [UIToolsControl initButtonWithFrame:CGRectMake(WIDTH-50*Scale, HeightOfStatusBar+3*Scale, 50*Scale, 36*Scale) imageName:nil target:self action:@selector(editBtnTap) title:@"电脑编辑" titleColor:THEMECOLOR_OF_ORANGE];
    editBtn.titleLabel.font = Font(Font_15);
    UIBarButtonItem *rightEditItem = [[UIBarButtonItem alloc] initWithCustomView:editBtn];
    self.navigationItem.rightBarButtonItems = @[rightItem, rightEditItem];
    
    UIView *topBgView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 40*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
    [self.view addSubview:topBgView];
    NSString *priceText = [NSString stringWithFormat:@"简历定价:%@元/次", (infoModel.price?infoModel.price:@"")];
    CGFloat priceWidth = [UIToolsControl textWidth:priceText size:CGSizeMake(MAXFLOAT, ViewHeight(topBgView)) font:Font_13]+20*Scale;
    UILabel *priceLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, 0, priceWidth, ViewHeight(topBgView)) text:priceText textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_13];
    [topBgView addSubview:priceLbl];
    NSMutableAttributedString *priceAtt = [[NSMutableAttributedString alloc] initWithString:priceText];
    [priceAtt addAttribute:NSForegroundColorAttributeName value:THEMECOLOR_OF_ORANGE range:NSMakeRange(0, priceText.length)];
    [priceAtt addAttribute:NSForegroundColorAttributeName value:THEMECOLOR_OF_TEXT_9a9a9a range:NSMakeRange(0, 5)];
    priceLbl.attributedText = priceAtt;
    NSString *integrityText = [NSString stringWithFormat:@"完整度:%@%@", (infoModel.percent?infoModel.percent:@""), @"%"];
    CGFloat integrityWidth = [UIToolsControl textWidth:integrityText size:CGSizeMake(MAXFLOAT, ViewHeight(topBgView)) font:Font_13]+20*Scale;
    UILabel *integrityLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(priceLbl), 0, integrityWidth, ViewHeight(topBgView)) text:integrityText textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_13];
    [topBgView addSubview:integrityLbl];
    NSMutableAttributedString *integrityAtt = [[NSMutableAttributedString alloc] initWithString:integrityText];
    [integrityAtt addAttribute:NSForegroundColorAttributeName value:THEMECOLOR_OF_GREEN range:NSMakeRange(0, integrityText.length)];
    [integrityAtt addAttribute:NSForegroundColorAttributeName value:THEMECOLOR_OF_TEXT_9a9a9a range:NSMakeRange(0, 4)];
    integrityLbl.attributedText = integrityAtt;
    switchBtn = [[UISwitch alloc] initWithFrame:CGRectMake(WIDTH-75*Scale, 3*Scale, 45*Scale, 22*Scale)];
    switchBtn.thumbTintColor = COLOR_OF_WHITE;
    switchBtn.onTintColor = THEMECOLOR_OF_ORANGE;
    switchBtn.on = [infoModel.status integerValue];
    [switchBtn addTarget:self action:@selector(switchBtnTap:) forControlEvents:UIControlEventValueChanged];
    switchBtn.transform = CGAffineTransformMakeScale(0.75, 0.75);
    [topBgView addSubview:switchBtn];
    UILabel *onLbl = [UIToolsControl initLabelWithFrame:CGRectMake(WIDTH-180*Scale, 0, 100*Scale, ViewHeight(topBgView)) text:@"简历开启:" textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_13];
    onLbl.textAlignment = NSTextAlignmentRight;
    [topBgView addSubview:onLbl];
    
    firstHeaderView = [[PMineResumeHeaderView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 355*Scale) target:self infoData:infoModel];
    
    resumeTableView = [UIToolsControl initTableViewWithFrame:CGRectMake(0, EndY(topBgView), WIDTH, HEIGHT-HeightOfStatusBarAndNavigationBar-SIMEmojKeyBoardkBottomNOSafeArea_Height-ViewHeight(topBgView)-68*Scale) target:self style:UITableViewStyleGrouped];
    resumeTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    resumeTableView.backgroundColor = COLOR_OF_WHITE;
    [self.view addSubview:resumeTableView];
    
    NSMutableArray *dataArray = [NSMutableArray arrayWithCapacity:0];
    for (PMineResumeTagsInfoModel *model in infoModel.tagsArray) {
        [dataArray addObject:model.tag_cn];
    }
    lastFooterView = [UIToolsControl initViewWithFrame: CGRectMake(0, 0, WIDTH, 55*Scale) backgroundColor:COLOR_OF_WHITE];
    [self initFooterView:dataArray];
    
    /*
    lastFooterView = [UIToolsControl initViewWithFrame: CGRectMake(0, 0, WIDTH, 60*Scale) backgroundColor:COLOR_OF_WHITE];
    UILabel *footerTitleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 60*Scale) text:@"附件简历" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_17];
    footerTitleLbl.font = FontBold(Font_17);
    [lastFooterView addSubview:footerTitleLbl];
    [footerTitleLbl borderColor:THEMECOLOR_OF_TEXT_cccccc borderWidth:lineH borderType:(BorderSideTypeTop | BorderSideTypeBottom)];
    UILabel *footerRightLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, 0, WIDTH-45*Scale, 60*Scale) text:((infoModel && infoModel.wordModel)?@"已经添加1份":@"请上传") textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_13];
    footerRightLbl.textAlignment = NSTextAlignmentRight;
    footerRightLbl.backgroundColor = COLOR_OF_CLEAR;
    [lastFooterView addSubview:footerRightLbl];
    UIImageView *rightImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(WIDTH-38*Scale, 23*Scale, 7*Scale, 13*Scale) imageName:@"jiantou_right"];
    [lastFooterView addSubview:rightImgView];
    UIButton *footerBtn = [UIToolsControl initButtonWithFrame:lastFooterView.bounds imageName:nil target:self action:@selector(footerBtnTap) title:nil titleColor:nil];
    [lastFooterView addSubview:footerBtn];
    */
    
    UIView *bottomBgView = [UIToolsControl initViewWithFrame:CGRectMake(0, HEIGHT-HeightOfStatusBarAndNavigationBar-SIMEmojKeyBoardkBottomNOSafeArea_Height-68*Scale, WIDTH, 68*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
    [self.view addSubview:bottomBgView];
    CGFloat btnWidth = (WIDTH-30*Scale)*0.5;
    UIButton *topBtn = [UIToolsControl initButtonWithFrame:CGRectMake(10*Scale, 10*Scale, btnWidth, 48*Scale) imageName:nil target:self action:@selector(topBtnTap) title:@"置顶" titleColor:THEMECOLOR_OF_TEXT_666666];
    topBtn.titleLabel.font = Font(Font_17);
    topBtn.layer.cornerRadius = 24*Scale;
    topBtn.layer.masksToBounds = YES;
    topBtn.backgroundColor = COLOR_OF_WHITE;
    [bottomBgView addSubview:topBtn];
    UIButton *checkBtn = [UIToolsControl initButtonWithFrame:CGRectMake(EndX(topBtn)+10*Scale, 10*Scale, btnWidth, 48*Scale) imageName:nil target:self action:@selector(checkBtnTap) title:@"预览" titleColor:COLOR_OF_WHITE];
    checkBtn.titleLabel.font = Font(Font_17);
    checkBtn.layer.cornerRadius = 24*Scale;
    checkBtn.layer.masksToBounds = YES;
    checkBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
    [bottomBgView addSubview:checkBtn];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 8;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    switch (section) {
        case 0: {
            return 1;
        } break;
        case 1: {
            if (infoModel && infoModel.workArray.count) {
                return infoModel.workArray.count;
            }
        } break;
        case 2: {
            if (infoModel && infoModel.educationArray.count) {
                return infoModel.educationArray.count;
            }
        } break;
        case 3: {
            if (infoModel && infoModel.trainingArray.count) {
                return infoModel.trainingArray.count;
            }
        } break;
        case 4: {
            if (infoModel && infoModel.projectArray.count) {
                return infoModel.projectArray.count;
            }
        } break;
        case 5: {
            if (infoModel && infoModel.credentArray.count) {
                return infoModel.credentArray.count;
            }
        } break;
        case 6: {
            if (infoModel && infoModel.languageArray.count) {
                return infoModel.languageArray.count;
            }
        } break;
        case 7: {
            return 1;
        } break;
        default:
            break;
    }
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PMineResumeCell *cell = [tableView dequeueReusableCellWithIdentifier:isCellID];
    if (!cell) {
        cell = [[PMineResumeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:isCellID];
    }
    
    [cell reloadData:infoModel indexPath:indexPath];
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.section) {
        case 0: { // 求职意向
            PMineResumeIntentionViewController *PMRIVC = [[PMineResumeIntentionViewController alloc] init];
            PMRIVC.delegate = self;
            if (infoModel && infoModel.intentionModel) {
                
            }
            [self.navigationController pushViewController:PMRIVC animated:YES];
        } break;
        case 1: { // 工作经历
            if (infoModel && infoModel.workArray.count) {
                PMineResumeWorkViewController *PMRWVC = [[PMineResumeWorkViewController alloc] init];
                PMRWVC.delegate = self;
                if (infoModel && infoModel.workArray.count) {
                    PMineResumeWorkInfoModel *model = [infoModel.workArray[indexPath.row] copy];
                    PMRWVC.type = AddOrEditTypeOfEdit;
                    PMRWVC.model = model;
                } else {
                    PMRWVC.type = AddOrEditTypeOfAdd;
                }
                [self.navigationController pushViewController:PMRWVC animated:YES];
            }
        } break;
        case 2: { // 教育经历
            PMineResumeEducationViewController *PMREVC = [[PMineResumeEducationViewController alloc] init];
            PMREVC.delegate = self;
            if (infoModel && infoModel.educationArray.count) {
                PMineResumeEducationInfoModel *model = [infoModel.educationArray[indexPath.row] copy];
                PMREVC.type = AddOrEditTypeOfEdit;
                PMREVC.model = model;
            } else {
                PMREVC.type = AddOrEditTypeOfAdd;
            }
            [self.navigationController pushViewController:PMREVC animated:YES];
        } break;
        case 3: { // 培训经历
            if (infoModel && infoModel.trainingArray.count) {
                PMineResumeTrainingViewController *PMRTVC = [[PMineResumeTrainingViewController alloc] init];
                PMRTVC.delegate = self;
                if (infoModel && infoModel.trainingArray.count) {
                    PMineResumeTrainingInfoModel *model = [infoModel.trainingArray[indexPath.row] copy];
                    PMRTVC.type = AddOrEditTypeOfEdit;
                    PMRTVC.model = model;
                } else {
                    PMRTVC.type = AddOrEditTypeOfAdd;
                }
                [self.navigationController pushViewController:PMRTVC animated:YES];
            }
        } break;
        case 4: { // 项目经历
            if (infoModel && infoModel.projectArray.count) {
                PMineResumeProjectViewController *PMRPVC = [[PMineResumeProjectViewController alloc] init];
                PMRPVC.delegate = self;
                if (infoModel && infoModel.projectArray.count) {
                    PMineResumeProjectInfoModel *model = [infoModel.projectArray[indexPath.row] copy];
                    PMRPVC.type = AddOrEditTypeOfEdit;
                    PMRPVC.model = model;
                } else {
                    PMRPVC.type = AddOrEditTypeOfAdd;
                }
                [self.navigationController pushViewController:PMRPVC animated:YES];
            }
        } break;
        case 5: { // 获得证书
            if (infoModel && infoModel.credentArray.count) {
                PMineResumeCredentViewController *PMRCVC = [[PMineResumeCredentViewController alloc] init];
                PMRCVC.delegate = self;
                if (infoModel && infoModel.credentArray.count) {
                    PMineResumeCredentInfoModel *model = [infoModel.credentArray[indexPath.row] copy];
                    PMRCVC.type = AddOrEditTypeOfEdit;
                    PMRCVC.model = model;
                } else {
                    PMRCVC.type = AddOrEditTypeOfAdd;
                }
                [self.navigationController pushViewController:PMRCVC animated:YES];
            }
        } break;
        case 6: { // 语言能力
            if (infoModel && infoModel.languageArray.count) {
                PMineResumeLanguageViewController *PMRLVC = [[PMineResumeLanguageViewController alloc] init];
                PMRLVC.delegate = self;
                if (infoModel && infoModel.languageArray.count) {
                    PMineResumeLanguageInfoModel *model = [infoModel.languageArray[indexPath.row] copy];
                    PMRLVC.type = AddOrEditTypeOfEdit;
                    PMRLVC.model = model;
                } else {
                    PMRLVC.type = AddOrEditTypeOfAdd;
                }
                [self.navigationController pushViewController:PMRLVC animated:YES];
            }
        } break;
        case 7: { // 特长标签
            if (infoModel && infoModel.tagsArray) {
                PMineResumeTagsViewController *PMRTVC = [[PMineResumeTagsViewController alloc] init];
                PMRTVC.delegate = self;
                if (infoModel && infoModel.tagsArray.count) {
                    PMRTVC.type = AddOrEditTypeOfEdit;
                    PMRTVC.tagsArray = [NSMutableArray arrayWithCapacity:0];
                    for (NSInteger i = 0; i < infoModel.tagsArray.count; i++) {
                        [PMRTVC.tagsArray addObject:[PMRTVC.tagsArray[i] copy]];
                    }
                    PMRTVC.tagsArray = infoModel.tagsArray;
                } else {
                    PMRTVC.type = AddOrEditTypeOfAdd;
                }
                [self.navigationController pushViewController:PMRTVC animated:YES];
            }
        } break;
        default:
            break;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.section) {
        case 0:
        case 1:
        case 2:
        case 3: {
            return 60*Scale;
        } break;
        case 4:
        case 5:
        case 6: {
            return 45*Scale;
        } break;
        case 7: {
//            return 55*Scale;
            return 0.00001;
        } break;
        default:
            break;
    }
    return 0.00001;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return 355*Scale;
    }
    return 45*Scale;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return firstHeaderView;
    } else {
        NSString *text = @"";
        NSString *btnText = @"添加";
        switch (section) {
            case 1: {
                text = @"工作经历";
            } break;
            case 2: {
                text = @"教育经历";
            } break;
            case 3: {
                text = @"培训经历";
            } break;
            case 4: {
                text = @"项目经历";
            } break;
            case 5: {
                text = @"获得证书";
            } break;
            case 6: {
                text = @"语言能力";
            } break;
            case 7: {
                text = @"特长标签";
                btnText = @"编辑";
            } break;
            default:
                break;
        }
        UIView *view = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 45*Scale) backgroundColor:COLOR_OF_WHITE];
        for (UIView *v in view.subviews) {
            [v removeFromSuperview];
        }
        UIView *view1 = [UIToolsControl initViewWithFrame:CGRectMake(30*Scale, 0, WIDTH-60*Scale, 45*Scale) backgroundColor:COLOR_OF_WHITE];
        [view addSubview:view1];
        UILabel *titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, 10*Scale, WIDTH-60*Scale, 35*Scale) text:text textColor:THEMECOLOR_OF_TEXT_333333 font:Font_17];
        [view addSubview:titleLbl];
        titleLbl.font = FontBold(Font_17);
        UIButton *btn = [UIToolsControl initButtonWithFrame:CGRectMake(WIDTH-90*Scale, 15*Scale, 90*Scale, 30*Scale) imageName:nil target:self action:@selector(addBtnTap:) title:btnText titleColor:THEMECOLOR_OF_ORANGE];
        btn.titleLabel.font = Font(Font_15);
        btn.section = section;
        [view addSubview:btn];
        [view1 borderColor:THEMECOLOR_OF_TEXT_cccccc borderWidth:lineH borderType:BorderSideTypeTop];
        
        return view;
    }
}
- (void)addBtnTap:(UIButton *)btn {
    switch (btn.section) {
        case 1: { // 工作经历
            NSLog(@"工作经历");
            PMineResumeWorkViewController *PMRWVC = [[PMineResumeWorkViewController alloc] init];
            PMRWVC.delegate = self;
            PMRWVC.type = AddOrEditTypeOfAdd;
            [self.navigationController pushViewController:PMRWVC animated:YES];
        } break;
        case 2: { // 教育经历
            NSLog(@"教育经历");
            PMineResumeEducationViewController *PMREVC = [[PMineResumeEducationViewController alloc] init];
            PMREVC.delegate = self;
            PMREVC.type = AddOrEditTypeOfAdd;
            [self.navigationController pushViewController:PMREVC animated:YES];
        } break;
        case 3: { // 培训经历
            NSLog(@"培训经历");
            PMineResumeTrainingViewController *PMRTVC = [[PMineResumeTrainingViewController alloc] init];
            PMRTVC.delegate = self;
            PMRTVC.type = AddOrEditTypeOfAdd;
            [self.navigationController pushViewController:PMRTVC animated:YES];
        } break;
        case 4: { // 项目经历
            NSLog(@"项目经历");
            PMineResumeProjectViewController *PMRPVC = [[PMineResumeProjectViewController alloc] init];
            PMRPVC.delegate = self;
            PMRPVC.type = AddOrEditTypeOfAdd;
            [self.navigationController pushViewController:PMRPVC animated:YES];
        } break;
        case 5: { // 获得证书
            NSLog(@"获得证书");
            PMineResumeCredentViewController *PMRCVC = [[PMineResumeCredentViewController alloc] init];
            PMRCVC.delegate = self;
            PMRCVC.type = AddOrEditTypeOfAdd;
            [self.navigationController pushViewController:PMRCVC animated:YES];
        } break;
        case 6: { // 语言能力
            NSLog(@"语言能力");
            PMineResumeLanguageViewController *PMRLVC = [[PMineResumeLanguageViewController alloc] init];
            PMRLVC.delegate = self;
            PMRLVC.type = AddOrEditTypeOfAdd;
            [self.navigationController pushViewController:PMRLVC animated:YES];
        } break;
        case 7: { // 特长标签
            PMineResumeTagsViewController *PMRTVC = [[PMineResumeTagsViewController alloc] init];
            PMRTVC.delegate = self;
            if (infoModel && infoModel.tagsArray.count) {
                PMRTVC.type = AddOrEditTypeOfEdit;
                PMRTVC.tagsArray = [NSMutableArray arrayWithCapacity:0];
                for (NSInteger i = 0; i < infoModel.tagsArray.count; i++) {
                    [PMRTVC.tagsArray addObject:[infoModel.tagsArray[i] copy]];
                }
            } else {
                PMRTVC.type = AddOrEditTypeOfAdd;
            }
            [self.navigationController pushViewController:PMRTVC animated:YES];
        } break;
        default:
            break;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
//    if (section == 7) {
//        return 120*Scale;
//    }
    if (section == 7) {
        return 55*Scale;
    }
    return 0.00001;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    if (section == 7) {
        return lastFooterView;
    }
    return nil;
}
- (void)footerBtnTap {
    NSLog(@"附件简历");
    SVPHUDSuccess(@"请在电脑端操作");
}
- (void)refreshBtnTap {
    NSLog(@"刷新");
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    
    [BaseNetManager requestWithMethod:POST path:Person_RefreshResume_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            SVPHUDSuccess(responseObject[@"msg"]);
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)switchBtnTap:(UISwitch *)switchButton {
    NSLog(@"switchBtn:%@", switchButton.on?@"YES":@"NO");
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:switchButton.on?@"1":@"0" forKey:@"status"];
    
    [BaseNetManager requestWithMethod:POST path:Person_SetResumeStatus_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            SVPHUDSuccess(responseObject[@"msg"]);
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)topBtnTap {
    NSLog(@"置顶");
    // 跳页面
    LYJobHuntingController *jobVC = [[LYJobHuntingController alloc] init];
    jobVC.service_alias = @"stick_resume";
    jobVC.setmeal_id = @"0";
    jobVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:jobVC animated:YES];
}
- (void)checkBtnTap {
    NSLog(@"预览");
    WorkerResumeViewController *WRVC = [[WorkerResumeViewController alloc] init];
    [self.navigationController pushViewController:WRVC animated:YES];
}
- (void)pMineResumeHeaderViewBaseInfoEdit {
    NSLog(@"基本信息编辑");
    MineBaseInfoViewController *MBIVC = [[MineBaseInfoViewController alloc] init];
    MBIVC.headerImg = ^(NSString *headerImgUrl) {
//        firstHeaderView
    };
    [self.navigationController pushViewController:MBIVC animated:YES];
}
- (void)pMineResumeHeaderViewBaseInfoSpecialty {
    NSLog(@"自我描述");
    PMineResumeSelfDescriptionViewController *PMRSDVC = [[PMineResumeSelfDescriptionViewController alloc] init];
    PMRSDVC.limitTextMaxNumber = 1000;
    PMRSDVC.titleStr = @"自我描述";
    PMRSDVC.delegate = self;
    PMRSDVC.mineSpecialtyFlag = YES;
    PMRSDVC.context = (infoModel.specialty&& infoModel.specialty.length)?infoModel.specialty:@"";
    [self.navigationController pushViewController:PMRSDVC animated:YES];
}
- (void)pMineResumeSelfDescriptionViewControllerBack:(NSString *)info {
    if (info && info.length) {
        infoModel.specialty = info;
//        [resumeTableView reloadData];
        [firstHeaderView reloadDataForSpecialty:@"已填写"];
    }
}
- (void)pMineResumeHeaderViewBaseInfoCurrentStatus {
    NSLog(@"求职状态");
    self.statusPickerView.hidden = NO;
}
- (void)psSingleRowViewCancel:(PSSingleRowView *)psSingleRowView {
    psSingleRowView.hidden = YES;
}
- (void)psSingleRowViewOk:(PublicCategoryElementModel *)model PSSingleRowView:(PSSingleRowView *)psSingleRowView {
    psSingleRowView.hidden = YES;
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:(UD_GetOForK(isResumeID)?UD_GetOForK(isResumeID):@"") forKey:@"resume_id"];
    [dic setObject:model.id forKey:@"current"];
    
    [BaseNetManager requestWithMethod:POST path:Person_SetCurrent_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            SVPHUDSuccess(responseObject[@"msg"]);
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)pMineResumeWorkViewControllerBackRefresh:(BOOL)refresh {
    if (refresh) {
        isRefreshFlag = YES;
        [self loadData];
    }
}
- (void)pMineResumeEducationViewControllerBackRefresh:(BOOL)refresh {
    if (refresh) {
        isRefreshFlag = YES;
        [self loadData];
    }
}
- (void)pMineResumeTrainingViewControllerBackRefresh:(BOOL)refresh {
    if (refresh) {
        isRefreshFlag = YES;
        [self loadData];
    }
}
- (void)pMineResumeProjectViewControllerBackRefresh:(BOOL)refresh {
    if (refresh) {
        isRefreshFlag = YES;
        [self loadData];
    }
}
- (void)pMineResumeCredentViewControllerBackRefresh:(BOOL)refresh {
    if (refresh) {
        isRefreshFlag = YES;
        [self loadData];
    }
}
- (void)pMineResumeLanguageViewControllerBackRefresh:(BOOL)refresh {
    if (refresh) {
        isRefreshFlag = YES;
        [self loadData];
    }
}
- (void)pMineResumeTagsViewControllerBackRefresh:(NSArray *)dataArray {
    if (dataArray.count) {
        [infoModel.tagsArray removeAllObjects];
        NSMutableArray *arr = [NSMutableArray arrayWithCapacity:0];
        for (PublicCategoryElementModel *model in dataArray) {
            [arr addObject:model.name];
            
            PMineResumeTagsInfoModel *tempModel = [[PMineResumeTagsInfoModel alloc] init];
            tempModel.tag_id = model.id;
            tempModel.tag_cn = model.name;
            [infoModel.tagsArray addObject:tempModel];
        }
        [self initFooterView:arr];
        [resumeTableView reloadData];
    }
}
- (void)pMineResumeIntentionViewControllerBackRefresh:(BOOL)refresh {
    if (refresh) {
        isRefreshFlag = YES;
        [self loadData];
    }
}
- (void)initFooterView:(NSArray *)dataArray {
    for (UIView *view in lastFooterView.subviews) {
        [view removeFromSuperview];
    }
    if (dataArray && dataArray.count) {
        UIScrollView *tagsScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(30*Scale, 5*Scale, WIDTH-60*Scale, 35*Scale)];
        [lastFooterView addSubview:tagsScrollView];
        CGFloat lblWidth = (WIDTH-70*Scale)*0.2;
        CGFloat endX = 0;
        for (NSInteger i = 0; i < dataArray.count; i++) {
            CGFloat textWidth = [UIToolsControl textWidth:dataArray[i] size:CGSizeMake(MAXFLOAT, CompanyTagsHeight) font:Font_13]+1;
            CGFloat width = ((lblWidth>textWidth)?lblWidth:textWidth);
            UILabel *lbl = [UIToolsControl initLabelWithFrame:CGRectMake(endX, 5*Scale, width, CompanyTagsHeight) text:dataArray[i] textColor:THEMECOLOR_OF_TEXT_666666 font:Font_13];
            lbl.textAlignment = NSTextAlignmentCenter;
            lbl.layer.cornerRadius = 2*Scale;
            lbl.layer.masksToBounds = YES;
            lbl.layer.borderColor = THEMECOLOR_OF_TEXT_cccccc.CGColor;
            lbl.layer.borderWidth = 0.5;
            [tagsScrollView addSubview:lbl];
            lbl.adjustsFontSizeToFitWidth = YES;
            endX = EndX(lbl)+5*Scale;
        }
        tagsScrollView.contentSize = CGSizeMake(endX+15*Scale, 0);
    } else {
        UILabel *lbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, 5*Scale, WIDTH-15*Scale, 35*Scale) text:@"待完善" textColor:THEMECOLOR_OF_TEXT_666666 font:Font_15];
        [lastFooterView addSubview:lbl];
    }
}

@end
